package com.zzl.rabbitmq.deadletter;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.zzl.rabbitmq.utils.RabbitMqUtils;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

/**
 * Title: DeadLetterConsumer01.class<br>
 * Description: 死信队列消费者<br>
 * Copyright (c)  2021    <br>
 * Create DateTime: 2021/7/15 13:06 <br>
 *
 * @author zhuangzhuangliang
 */
public class DeadLetterConsumer02 {


    public static final String DEAD_EXCHANGE ="dead_exchange";
    public static final String DEAD_QUEUE ="dead_queue";

    public static void main(String[] args) throws Exception{

        //声明交换机和队列
        Channel channel = RabbitMqUtils.getChannel();

        DeliverCallback deliverCallback = (consumerTag,message)->{

            System.out.println("接收到消息: "+new String(message.getBody(), StandardCharsets.UTF_8));
        };
        channel.basicConsume(DEAD_QUEUE,deliverCallback,consumerTag -> {});
    }
}
